package com.cskaoyan.controller.wx.sl;

import com.cskaoyan.bo.wx.sl.WxCollectAddordeleteBo;
import com.cskaoyan.service.wx.sl.WxCollectsService;
import com.cskaoyan.vo.BaseRespVo;
import com.cskaoyan.vo.wx.sl.WxCollectListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WxCollectsController {

    @Autowired
    WxCollectsService wxCollectsService;

    //显示收藏列表
    @RequestMapping("wx/collect/list") //type=0&page=1&size=10
    public BaseRespVo collectList(byte type,Integer page,Integer size){
        WxCollectListVo wxCollectListVo = wxCollectsService.collectList(type,page,size);
        return BaseRespVo.ok(wxCollectListVo);
    }
    //添加或取消收藏
    @RequestMapping("wx/collect/addordelete")
    public BaseRespVo collectAddordelete(@RequestBody WxCollectAddordeleteBo wxCollectAddordeleteBo){
        //返回200是添加成功，返回2是删除成功
        int ant = wxCollectsService.collectAddordelete(wxCollectAddordeleteBo);
        String type = "add";
        if (ant == 200){
        return BaseRespVo.ok(type);
        }
        type = "delete";
        return BaseRespVo.ok(type);
    }
}
